package com.example.demo;

import com.example.demo.aop.TestService;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

/**
 * @Created on 2021/4/4.
 * @Author by zbk
 * @Description:
 */
@Configuration
@EnableAspectJAutoProxy
@ComponentScan("com.example.demo.aop")
public class AnnotationMain {

    public static void main(String[] args) {

        AnnotationConfigApplicationContext a = new AnnotationConfigApplicationContext(AnnotationMain.class);
        TestService testService = a.getBean("testService", TestService.class);
        testService.doTest();
        System.out.println(testService);

        a.publishEvent(new ApplicationEvent("我发布的事件") {

        });


    }

}
